package BackTrackingSeries;

import java.util.ArrayList;
import java.util.List;

public class SubSetsSolution_78 {
    List<List<Integer>> res = new ArrayList<>();
    List<Integer> subRes = new ArrayList<>();

    public List<List<Integer>> subsets(int[] nums) {
        backTracking(nums, 0);
        return res;
    }

    public void backTracking(int[] nums, int index) {
        res.add(new ArrayList<>(subRes));
        if (index > nums.length - 1) {
            return;
        }

        for (int i = index; i < nums.length - 1; i++) {
            subRes.add(nums[i]);
            backTracking(nums, i + 1);
            subRes.remove(subRes.size() - 1);
        }
    }
}
